﻿using System.Collections.Generic;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SharePoint.Orm.Wrappers {
	public interface ISPOrmUser : ISPOrmPrincipal {
		/// <summary>
		/// The loginname of the user.
		/// </summary>
		string LoginName { get; }

		/// <summary>
		/// The email address of the user.
		/// </summary>
		string Email { get; }

		/// <summary>
		/// Gets a <see cref="PickerEntity"/> used with the <see cref="PeopleEditor"/> web control.
		/// </summary>
		PickerEntity ToPickerEntity();

		/// <summary>
		/// The groups this user belongs to.
		/// </summary>
		IEnumerable<ISPOrmGroup> GetGroups();

		SPFieldUserValue GetSPFieldUserValue(SPDataContext ctx);

		///<summary>
		/// Gets a property value from the SiteUserInfoList. eg Office.
		///</summary>
		///<param name="ctx">An open SPOrm data context</param>
		///<param name="propertyName">The name of the property to get (eg Office)</param>
		///<returns>The property value.</returns>
		///<exception cref="SPOrmException">If the user cannot be found.</exception>
		object GetSiteUserInfoPropertyValue(SPDataContext ctx, string propertyName);

		///<summary>
		/// Checks that the user is in at least one of the supplied groups.
		///</summary>
		///<param name="groups">The list of groups to check.</param>
		///<returns>true, if the user is in at least one of the groups. false, otherwise.</returns>
		bool IsInAtLeastOneGroup(IEnumerable<string> groups);
	}
}